<?php

class importexport_data_b2c_business_orders {


    /**
     * 导出供应商采购订单数据，修改数据库已有数据
     *
     * @params array $row 数据库中一条会员数据
     * @return array $row 修改过后的数据
     */
    //public function get_content_row($row){
    // $purchase_data = kernel::single('b2c_business_orders_objects')->get_pam_data('*',$row['member_id']);
    // $row['member_id'] = $purchase_data['local'];
    // $row['mobile'] = $purchase_data['mobile'];
    // $row['email'] = $purchase_data['email'];
    // $data[0] = $row;
    // return $data;
    //}//end function

    /**
     * 导出订单数据，修改数据库已有数据
     *
     * @params array $row 数据库中一条订单数据
     * @return array $row 修改过后的数据
     */
    public function get_content_row($row){
        if(!$this->title){
            $this->title = $this->get_title();
        }
        //查询model里修改后的采购订单列表数据
        $purchase_data = app::get('b2c')->model('business_orders_objects')->get_finder_objects_export('*',array('obj_id'=>$row['obj_id']));

        if(!empty($purchase_data)){
            $data = array();
            $data['english_all_name'] = $purchase_data[0]['english_all_name'];
            $data['mainOrder_id'] = $purchase_data[0]['mainOrder_id'];
            $data['createtime'] = date("d-m-Y h:i:s",$purchase_data[0]['createtime']);
            $data['bn'] = $purchase_data[0]['bn'];
            $data['brand_name'] = $purchase_data[0]['brand_name'];
            $data['has_confirm_num'] = $purchase_data[0]['has_confirm_num'];
            $data['quantity'] = $purchase_data[0]['quantity'];
            $data['unit_num'] = $purchase_data[0]['unit_num'];
            $data['s_cost'] = round($purchase_data[0]['s_cost']);
            $data['confirm_time'] = $purchase_data[0]['confirm_time'] ? date("d-m-Y h:i:s",$purchase_data[0]['confirm_time']) :'';
            //$data = $purchase_data;
            $rs[] = $data;

        }
        return $rs;
        //$this->redis = kernel::single('base_kvstore_redis');
        //$this->redis->store('key009',$rs);
    }


    public function get_title(){
        $title = array(
            'english_all_name' => app::get('b2c')->_('供应商名称'),
            'mainOrder_id'     => app::get('b2c')->_('主订单号'),
            'createtime'       => app::get('b2c')->_('创建时间'),
            'bn'               => app::get('b2c')->_('货品编号'),
            'brand_name'       => app::get('b2c')->_('品牌'),
            'has_confirm_num'  => app::get('b2c')->_('已确认数量'),
            'quantity'         => app::get('b2c')->_('数量(包装)'),
            'unit_num'         => app::get('b2c')->_('每包装数量'),
            'cost'             => app::get('b2c')->_('采购价'),
            'confirm_time'     => app::get('b2c')->_('库存确认时间'),
        );
        return $title;
    }

}
